Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@golem-sdk/golem-js
Advanced tools
NodeJS and WebBrowser SDK for building apps running on Golem Network
Become a Requestor in the Golem Network and use this SDK to:
golem-js
?The Golem Network fosters a global group of creators building ambitious software solutions that will shape the technological landscape of future generations by accessing computing resources across the platform. Golem Network is an accessible, reliable, open access and censorship-resistant protocol, democratizing access to digital resources and connecting users through a flexible, open-source platform.
golem-js is the JavaScript API that allows developers to connect to their Golem nodes and manage their distributed, computational loads through Golem Network.
To quickly get started with a new project using golem-js
, you can use the following template:
npx @golem-sdk/cli@latest new my-awesome-golem-project
@golem-sdk/golem-js
is available as a NPM package.
You can install it through npm
:
npm install @golem-sdk/golem-js
or by yarn
:
yarn add @golem-sdk/golem-js
The SDK is designed to work with LTS versions of Node (starting from 18)
and with browsers. The minimum supported yagna
version is 0.15.2
.
Before you start using the SDK, you need to have yagna
installed and running on your machine. Yagna is a service that
communicates and performs operations on the Golem Network, upon your requests via the SDK. You can follow the
instructions below or visit
the official documentation
to set it up.
# Join the network as a requestor
curl -sSf https://join.golem.network/as-requestor | bash -
# Start the golem node on your machine,
# you can use `daemonize` to run this in background
yagna service run
Now that you have yagna
running, you can initialize your requestor and request funds (tGLM
tokens) on the test
network.
# IN SEPARATE TERMINAL (if not daemonized)
# Initialize your requestor
yagna payment init --sender --network holesky
# Request funds on the test network
yagna payment fund --network holesky
# Check the status of the funds
yagna payment status --network holesky
app-key
to use with SDKIf you don't have any app-keys available from yagna app-key list
, go ahead and create one with the command below.
You will need this key in order to communicate with yagna
from your application. You can set it
as YAGNA_APPKEY
environment variable.
yagna app-key create my-golem-app
You can rent a single machine and run a simple task on it:
import { MarketOrderSpec, GolemNetwork } from "@golem-sdk/golem-js";
// Define the order that we're going to place on the market
const order: MarketOrderSpec = {
demand: {
workload: { imageTag: "golem/alpine:latest" },
},
market: {
// We're only going to rent the provider for 5 minutes max
rentHours: 15 / 60,
pricing: {
model: "linear",
maxStartPrice: 0.5,
maxCpuPerHourPrice: 1.0,
maxEnvPerHourPrice: 0.5,
},
},
};
(async () => {
const glm = new GolemNetwork();
try {
await glm.connect();
// Rent a machine
const rental = await glm.oneOf({ order });
await rental
.getExeUnit()
.then((exe) => exe.run("echo Hello, Golem! 👋"))
.then((res) => console.log(res.stdout));
await rental.stopAndFinalize();
} catch (err) {
console.error("Failed to run the example", err);
} finally {
await glm.disconnect();
}
})().catch(console.error);
Read about other available usage patterns to learn more on how you can leverage the SDK.
The examples directory in the repository contains various usage patterns for the SDK. You can browse through them and learn about the recommended practices. All examples are automatically tested during our release process.
You can find even more examples and tutorials in the JavaScript API section of the Golem Network Docs.
Visit our official documentation to learn more about the JavaScript SDK and how to use it.
The SDK uses the debug package to provide debug logs. To enable them, set
the DEBUG
environment variable to golem-js:*
or golem-js:market:*
to see all logs or only the market-related ones,
respectively. For more information, please refer to
the debug package documentation.
Read the dedicated testing documentation to learn more about how to run tests of the SDK.
Read the Contributing Guide for details on how you can get involved. In case you find an issue with the examples or the SDK itself, feel free to submit an issue report to the repository.
Feel invited to join our Discord. You can meet other SDK users and developers in the #sdk-discussion
and #js-discussion
channels.
FAQs
NodeJS and WebBrowser SDK for building apps running on Golem Network
The npm package @golem-sdk/golem-js receives a total of 0 weekly downloads. As such, @golem-sdk/golem-js popularity was classified as not popular.
We found that @golem-sdk/golem-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.